//
//  GYX_SearchBarViewController.m
//  MELive
//
//  Created by dllo on 16/10/22.
//  Copyright © 2016年 雅馨. All rights reserved.
//

#import "GYX_SearchBarViewController.h"
#import "AFNetworking.h"
#import "Macro.h"
@interface GYX_SearchBarViewController ()<UISearchBarDelegate, UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UISearchBar *BYsearchTextFd;
@property (nonatomic, strong) UITableView *tableView;
@end

@implementation GYX_SearchBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self creatSearchBar];
//    [self handleData];
//    [self creatTableView];
}
- (void)handleData {
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    [manager.requestSerializer setValue:@"961c99a0-e574-4054-98cd-6e0f20bcc62b" forHTTPHeaderField:@"token"];
    
    [manager GET:@"http://api1.naonaola.com/room/latest/v2?page=0&pageSize=20" parameters:nil progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSLog(@"%@", responseObject);
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSLog(@"error = %@", error);
    }];
}
- (void)creatSearchBar {
    self.navigationController.navigationBar.tintColor = [UIColor blackColor];
    self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;
    self.BYsearchTextFd = [[UISearchBar alloc]initWithFrame:CGRectMake(0, 0,SCREEN_WIDTH,44)];
    self.BYsearchTextFd.placeholder = @"搜索用户或话题";
    self.BYsearchTextFd.barStyle = UIBarStyleDefault;
    self.BYsearchTextFd.delegate = self;
    self.BYsearchTextFd.searchBarStyle = UISearchBarStyleProminent;
    self.navigationItem.titleView = self.BYsearchTextFd;
    UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonItemStylePlain target:self action:@selector(clickCancelButton:)];
    self.navigationItem.rightBarButtonItem = cancelButton;
    self.navigationItem.hidesBackButton = YES;
}
- (void)creatTableView {
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height - 49 - 64) style:UITableViewStyleGrouped];
    [self.view addSubview:_tableView];
    _tableView.dataSource = self;
    _tableView.delegate = self;
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}
- (void)clickCancelButton:(UIBarButtonItem *)sender {
    [self.BYsearchTextFd resignFirstResponder];
    [self.navigationController popViewControllerAnimated:YES];
}
@end
